/* Teach Tool  - Structural Dynamics
 * Copyright (C) 2009: Fabian Gerold, www.fabiangerold.de
 *
 * This file may be licensed under the terms of of the
 * GNU General Public License Version 3 (the "GPL").
 * 
 * Software distributed under the License is distributed 
 * on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
 * express or implied. See the GPL for the specific language 
 * governing rights and limitations.
 *
 * You should have received a copy of the GPL along with this 
 * program. If not, go to http://www.gnu.org/licenses/gpl.html
 * or write to the Free Software Foundation, Inc., 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef SystemHarm_H
#define SystemHarm_H

#include "../src_common/System.h"

#include <QTimer>

class SystemHarm : public System
{
   Q_OBJECT

public:
	SystemHarm();
	
	void setSpring( double k );
	void setMass( double m );
	void setDamp( double d );
	void setAmp( double a );
	
	void setMode( int mode );
	void setOmegaF( double omega );
	void setF0( double f );
	void setOmegaG( double omega );
	void setG0( double a );

	bool isStopped() { return m_halted; }
	void parameter();
	
	void setTxtOutput( int out );
	float addScale( float scale );
	
	//void start();
	void proceed();
	void reset();
	void restoreExcitationPath();

signals:
	void signalClearPoints();
	void signalUpdateParameter(double,double,double,double);
	void signalUpdateTime(double);
	void signalClearOutput();
	void signalResetDisp();

	void signalDiagSetMax( float, float, float );
	void signalDiagUpdate();
	void signalDiagAddPoint(  float, float, float, float  );
	void signalDiagSetScale(float);

	void signalSetDisp( double, double );
	void signalSetDragDisp( double );
	void signalSetSpring( double );
	void signalSetMass( double );
	void signalSetDamp( double );

	void signalSetForce( double );
	void signalSetForceVisible( bool );
	void signalSetExcitation( QPainterPath* path, int mode );

public slots:
	void slotStart( double amp = 0 );
	void slotStop();
	void slotFrame();
	void slotSetDragDisp( double ) { }
	

private:
	void step();

	QTimer		m_timer;
	int			m_timestep;
	double		m_sec;
	float		m_diag_scale;
	double		m_u;
	double		m_up;
	double		m_upp;
	double		m_u1;
	double		m_u2;
	double		m_up1;
	double		m_up2;
	double		m_upp1;
	double		m_upp2;
	double		m_ub;
	double		m_ub1;
	double		m_amp;
	double		m_force;
	double		m_force1;
	bool		m_halted;
	bool		m_paint;
	
	// parameters
	double		m_k;
	double		m_m;
	double		m_T;
	double		m_f;
	double		m_omega;
	double		m_omega_d;
	double		m_xi;
	double		m_fi;
	double		m_c;

	bool		m_show_u;
	bool		m_show_up;
	bool		m_show_upp;

	// text output
	QString		m_output;
	QString		m_output_buff;
	bool		m_buff_output;
	int			m_txt_out;
	int			m_stop_output;

	double		m_dt;
	int			m_mode;
	double		m_F0;
	double		m_omega_F;
	double		m_G0;
	double		m_omega_G;
	

	// newmark
	double	m_delta;
	double	m_alpha;
	double	m_a0;
	double	m_a1;
	double	m_a2;
	double	m_a3;
	double	m_a4;
	double	m_a5;
	double	m_a6;
	double	m_a7;
};

#endif
